package com.sdy.kzyy.pc.controller;

import com.sdy.common.model.BizException;
import com.sdy.common.model.Response;
import com.sdy.kzyy.biz.dto.AppointDateDTO;
import com.sdy.kzyy.biz.service.KeyValueConfigurationsService;
import com.sdy.kzyy.biz.service.StoreService;
import com.sdy.mvc.controller.BaseController;
import io.swagger.annotations.*;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author cgj
 * @since 2020-03-26
 */
@Slf4j
@RestController
@SuppressWarnings("unchecked")
@RequestMapping("/appointmentRules")
@Api(tags = "预约规则设置")
public class AppointmentRulesController extends BaseController {
    @Autowired
    private StoreService storeService;
    @Autowired
    private KeyValueConfigurationsService keyValueConfigurationsService;

    @GetMapping("/getAppointDate")
    @ResponseBody
    @ApiOperation(value = "获取当前数据", response = AppointDateDTO.class)
    public Response<AppointDateDTO> getAppointDate() {
        AppointDateDTO appointDateDTO = keyValueConfigurationsService.getAppointDateDTO();
        return Response.success(appointDateDTO);
    }

    @PostMapping("updateAppointDate")
    @ApiOperation(value = "修改当前数据", response = AppointDateDTO.class)
    public Response updateAppointDate(@RequestBody @ApiParam(value = "appointDateDTO",name = "实体类") AppointDateDTO appointDateDTO) throws BizException {
        Boolean aBoolean = keyValueConfigurationsService.updateAppointDate(appointDateDTO);
        return Response.success(aBoolean);
    }

}
